<!-- 
    //获取canvas元素
    let canvas = document.getElementById('tutorial')
    //获取2d绘制上下文
    if (canvas.getContext) {
        var ctx = canvas.getContext('2d');
    }
 -->
<html>
<head>
    <title>Canvas tutorial</title>
    <script type="text/javascript">
        function draw() {
            var canvas = document.getElementById('canvas');
            if (canvas.getContext) {
                var ctx = canvas.getContext('2d');
            }
        }
    </script>
    <style type="text/css">
        canvas {
            border: 1px solid black;
        }
    </style>
</head>

<body onload="draw();">
    <canvas id="canvas" width="150" height="150"></canvas>
</body>

</html>